
from flask import Flask
import MySQLdb
from flask.ext.sqlalchemy import SQLAlchemy


app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://saas1:olymtech1@192.168.1.231:3306/cp_membership'
db = SQLAlchemy(app)

class mem_user(db.Model):
    org_id=db.Column(db.Integer,unique=True)
    user_id=db.Column(db.Integer,unique=True)
    user_name=db.Column(db.Integer,primary_key=True)

    def __init__(self, org_id, user_id, user_name):
        self.org_id = org_id
        self.user_id = user_id
        self.user_name= user_name

    def to_json(self):
        return{
            'org_id':str(self.org_id),
            'user_id':str(self.user_id),
            'user_name':self.user_name
        }
select_=mem_user.query.filter_by(org_id=10045).first()
print select_.user_id

